package com.googlecode.gwtbb.client.only.widget.display.picture;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.googlecode.gwtbb.client.shared.entity.picture.ImageProperties;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Aug 6, 2008
 */
public class CaptionedImage extends Composite {
	private PropImage propImage;
	private Label captionLabel;

	public CaptionedImage(ImageProperties imgProperties, String caption) {
		this(imgProperties, imgProperties.getWidth(), imgProperties.getHeight(), caption);
	}

	public CaptionedImage(ImageProperties imgProperties, int maxWidth, int maxHeight, String caption) {
		VerticalPanel panel = new VerticalPanel();
		initWidget(panel);
		panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
		propImage = new PropImage(imgProperties, maxWidth, maxHeight);
		panel.add(propImage);
		captionLabel = new Label(caption);
		panel.add(captionLabel);
	}

	public Label getCaptionLabel() {
		return captionLabel;
	}

	public PropImage getPropImage() {
		return propImage;
	}
}
